#pragma once

class EntMgr 
{
public:
	//=== vars ===//
	irr::core::list<EntBase *>		m_lstEntities;		// list of entities
	S32								m_s32NextEntId;		// next id to assign to entity
	VxIrrBase *						m_poIrrBase;

	//=== constructor ===//
	EntMgr();
	//=== destructor ===//
	~EntMgr();

	//! startup
	RCODE	Startup( VxIrrBase * poIrrBase );

	//! shutdown
	void	Shutdown( void );

	//=== properties ===//
	int			GetEntCount() const						{ return m_lstEntities.getSize(); }
	const irr::core::list<EntBase *> & GetEnts() const	{ return m_lstEntities; }

	//=== methods ===//
	void		Update( U32 u32FrameTimeMs );
	//! called once per second
	void		OncePerSecond( void );

	//! interpolate between positions
	void		InterpolatePositions( F32 f32BlendFactor );
	//! frame is about to be rendered
	void		BeginFrame( void );
	//! frame has been rendered
	void		EndFrame( void );

	//! add entity to list of entities
	EntBase *	AddEnt( EntBase * poEnt );
	//! remove entity from list of entities
	void		DeleteEnt( EntBase * poEnt );
	//! remove entity from list of entities
	void		DeleteEntById( S32 s32Id );
	//! find entity by common name
	EntBase *	GetEntByCommonName( const irr::core::stringc& strName );
	//! find entity by common name
	EntBase *	GetEntByProperName( const irr::core::stringc& strName );
	//! find entity by Id
	EntBase *	GetEntById( S32 s32Id );
	//! find entity by type ( returns first match found )
	EntBase *	GetEntByType( int iType );

	//! clear all entities form list
	void		ClearEnts( void );

};

// singleton
typedef VxSingleton<EntMgr> EntMgrImp;



